#include "companyinfodialog.h"
#include "ui_companyinfodialog.h"

CompanyInfoDialog::CompanyInfoDialog(int styleId,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CompanyInfoDialog)
{
    ui->setupUi(this);

    ui->enterWeb_Btn->setEnabled(false);//暂时注释
    move(0,0);
    initialDisplayStyle(styleId);

//#ifdef BUILD_ARM
//    setGeometry(70,128,460,595);
//#endif
}

void CompanyInfoDialog::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        this->setGeometry(0,0,600,450);
        ui->label_companyImage->setGeometry(0,0,600,400);
        ui->enterWeb_Btn->setGeometry(200,400,200,40);
        ui->returnBtn->setGeometry(510,400,70,40);
        break;
    default:
        break;
    }
}

CompanyInfoDialog::~CompanyInfoDialog()
{
    delete ui;
}

void CompanyInfoDialog::changeLanguage()
{
    ui->retranslateUi(this);
}

void CompanyInfoDialog::updateCompanyPictureShow(std::string imageStringIn)
{
    QPixmap imgOut=stringTopixmap( QString::fromStdString(imageStringIn) );
    ui->label_companyImage->setPixmap(imgOut);
    ui->label_companyImage->setScaledContents(true);
}

void CompanyInfoDialog::on_returnBtn_clicked()
{
    this->hide();
}

void CompanyInfoDialog::on_enterWeb_Btn_clicked()
{

}

QPixmap CompanyInfoDialog::stringTopixmap(const QString &pic)
{
    QByteArray byte_array = QByteArray::fromBase64(pic.toLocal8Bit());
    QPixmap pix;
    QDataStream data_stream(&byte_array,QIODevice::ReadOnly);
    data_stream>>pix;
    return pix;
}
